import * as ACTION from '../actions/topAction';

export const DEFAULT_STATE = {
	message: '',
	messageType: ACTION.ENUM_INFO_TYPE.INFO,
	open: false
};

export function topInfo(state = DEFAULT_STATE, action = {}) {
	let { type } = action;

	switch(type) {
		case ACTION.SEND_TOP_INFO:
			let { payload } = action;
			let { message = '', messageType = ACTION.ENUM_INFO_TYPE.INFO } = payload;
			return Object.assign({}, state, { message, messageType, open: true });
		case ACTION.CLOSE_TOP_INFO:
			return Object.assign({}, state, { open: false, message: '' });
		default:
			return state;
	}
};